﻿// basetool_demo.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include "SLT_tool_pub.h"
#include "SL_asynFramePub.h"


class testObj : public SLT_memLeakCheck< testObj>
{
public:
    int test = 0;
};

int main()
{
    SLT_logInit();

    //内存监控
    SLT_memLeakInit(3,true);
    testObj* pnew = new testObj();
    SLT_sleep(5000);
    SLT_LOG_ERR("delete obj");
    delete pnew;

    //内存操作，等价于 std::shared_ptr<char> data = std::make_shared<char>(10);  在linux版本上SLT_memDataSptr性能高
    SLT_memDataSptr data(SLT_memData::newData(10));
    memcpy(data->m_pbuf, "hello", 5);
    data->m_len = 5;
    
    //内存操作封装
    char *testbuf = (char*)"hello world";
    SLT_memBuf  m_buf;
    m_buf.add(testbuf,strlen(testbuf)+1);
    printf("%s\n",m_buf.get());
    m_buf.add(testbuf + 5, m_buf.getLen() - 5);
    printf("%s\n", m_buf.get());

    //sl_createTcpServer
    printf("press enter exit\n");
    getchar();
}

